package com.qiyeji.real_estate.service;

import com.qiyeji.real_estate.entity.department;
import com.qiyeji.real_estate.mapper.departmentMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class DepartmentService {
    @Autowired
    departmentMapper departmentMapper;

    // 获得全部部门的信息
    public List<department> getAllDepartment() {
        List<department> res = departmentMapper.getAllDepartment();

        return res;
    }

    // 添加部门信息
    public Integer addDepartment(department record) {
        Integer res = departmentMapper.insertSelective(record);

        return res;
    }

    //通过部门编号删除部门
    public Integer deleteDepartment(String dCode) {
        Integer res = departmentMapper.deleteByPrimaryKey(dCode);

        return res;
    }

    //通过项目编号修改部门
    public Integer alterDepartment(department record) {
        Integer res = departmentMapper.updateByPrimaryKeySelective(record);

        return res;
    }

    //通过部门编号查询部门信息
    public department queryDepartment(String dCode) {
        department res = departmentMapper.selectByPrimaryKey(dCode);

        return res;
    }

}
